﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UIOffset : MonoBehaviour {
	GameObject m_ObjSet;
	InputField m_xAxis, m_yAxis, m_zAxis, m_OffsetValue;
	UIOffset(GameObject obj)
	{
		SetOffsetObj (obj);
	}
	void SetName(string name)
	{
		m_ObjSet.name = name;
	}

	string GetName()
	{
		return m_ObjSet.name;
	}
	void SetOffsetObj(GameObject obj)
	{
		m_ObjSet = obj;
		InputField[] inputObjs = m_ObjSet.GetComponentsInChildren<InputField> ();
		foreach (InputField input in inputObjs) 
		{
			if (input.name == "xAxisValue") 
			{
				m_xAxis = input;
			}
			if (input.name == "yAxisValue") 
			{
				m_yAxis = input;
			}
			if (input.name == "zAxisValue") 
			{
				m_zAxis = input;
			}
			if (input.name == "offsetValue") 
			{
				m_OffsetValue = input;
			}
		}
	}

	Vector3 GetOffsetDir()
	{
		float x = float.Parse(m_xAxis.text);
		float y = float.Parse(m_yAxis.text);
		float z = float.Parse(m_zAxis.text);
		Vector3 ret= new Vector3(x, y, z);
		ret.Normalize ();
		return ret;
	}

	float GetOffsetValue()
	{
		return float.Parse(m_OffsetValue.text);
	}
}

public class UIRotate : MonoBehaviour {
	GameObject m_ObjSet;
	InputField m_xAxis, m_yAxis, m_zAxis, m_RotateValue;
	UIRotate(GameObject obj)
	{
		SetRotateObj (obj);
	}
	void SetRotateObj(GameObject obj)
	{
		m_ObjSet = obj;
		InputField[] inputObjs = m_ObjSet.GetComponentsInChildren<InputField> ();
		foreach (InputField input in inputObjs) 
		{
			if (input.name == "xAxisValue") 
			{
				m_xAxis = input;
			}
			if (input.name == "yAxisValue") 
			{
				m_yAxis = input;
			}
			if (input.name == "zAxisValue") 
			{
				m_zAxis = input;
			}
			if (input.name == "rotateValue") 
			{
				m_RotateValue = input;
			}
		}
	}

	Vector3 GetRotateDir()
	{
		float x = float.Parse(m_xAxis.text);
		float y = float.Parse(m_yAxis.text);
		float z = float.Parse(m_zAxis.text);
		Vector3 ret= new Vector3(x, y, z);
		ret.Normalize ();
		return ret;
	}

	float GetRotateValue()
	{
		return float.Parse(m_RotateValue.text);
	}
}
